package data;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class StockReader
{
	public StockReader()
	{
	}

	private String	sinaUrl	= "http://hq.sinajs.cn/list=";

	public void readSina(String code)
	{
		try
		{
			URL url = new URL(sinaUrl + code);
			URLConnection connection = url.openConnection();
			BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			String line = null;
			while ((line = in.readLine()) != null)
			{
				System.out.println(line);
			}
			in.close();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}

	public static void main(String argv[]) throws Exception
	{
		StockReader reader = new StockReader();
		long start = System.currentTimeMillis();
		String sinaCode = "sh600744,sh600295,sh600668,sz300006,sh600395,sh600582,sz000777,sh600123,sz000937,sz000767,"
				+ "sz000931,sz000511,sz002024,sh601106,sh600875,sh600720,sh600496,sz300191,sz000973,sz000709,sz000960,"
				+ "sz002104,sz000570,sz300022,sh600715,sh600868,sz000936,sz002438,sh600634,sh600898,sz000831,sz000820,"
				+ "sh600876,sz001896,sz000656,sh600730,sh600549,sh600348,sz000973,sz000570";
		reader.readSina(sinaCode);
		long end = System.currentTimeMillis();
		System.out.println("cost " + (end - start));
	}
}
